<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    const moveZeroes = nums => {
      const fun = (arr, l, r) => {
        let temp = arr[l]
        arr[l] = arr[r]
        arr[r] = temp
      }

      let l = 0, r = 0
      while (r < nums.length) {
        if (nums[r] !== 0) {
          fun(nums, l, r)
          l++
        }
        r++
      }
      return nums
    };

    console.log(moveZeroes([2, 3, 0, 1, 0, 0]));
  </script>
</body>

</html>